package cn.silver.module.quartz.domain;

import cn.silver.framework.mybatis.annotation.Table;
import cn.silver.framework.mybatis.domain.BusEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serial;

/**
 * 定时任务调度表 sys_job
 *
 * @author hb
 */
@Data
@NoArgsConstructor
@Table(name = "sys_job")
@EqualsAndHashCode(callSuper = true)
@Schema(name = "SysJob", description = "定时任务调度表")
public class SysJob extends BusEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 任务名称
     */
    @Schema(title = "任务名称")
    private String jobName;

    /**
     * 任务组名
     */
    @Schema(title = "任务组名")
    private String jobGroup;

    /**
     * 调用目标字符串
     */
    @Schema(title = "调用目标字符串")
    private String invokeTarget;

    /**
     * cron执行表达式
     */
    @Schema(title = "cron执行表达式")
    private String cronExpression;

    /**
     * cron计划策略
     */
    @Schema(title = "cron计划策略")
    private String misfirePolicy;

    /**
     * 是否并发执行（0允许 1禁止）
     */
    @Schema(title = "是否并发执行（0允许 1禁止）")
    private Boolean concurrent;

    /**
     * 任务状态（0正常 1暂停）
     */
    @Schema(title = "任务状态（0正常 1暂停）")
    private String status;


    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("jobId", getId())
                .append("jobName", getJobName())
                .append("jobGroup", getJobGroup())
                .append("cronExpression", getCronExpression())
                .append("misfirePolicy", getMisfirePolicy())
                .append("concurrent", getConcurrent())
                .append("status", getStatus())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }
}
